package Exercise.Four;

//.定义一个隧道类，实现 Runnable 接口：
public class Tunnel implements Runnable {
    private String name;

    public Tunnel(String name) {
        this.name = name;
    }

    public Tunnel() {

    }

    @Override
    public void run() {
        //每个人通过山洞的时间为5秒
        function(name);
    }
    public synchronized static void function(String name){
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(name+"通过了隧道");
    }
}
